package com.gjy.pd.bridge;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2022-12-30 15:27:54
 */
public class Client {

    public static void main(String[] args) {
        IImplement iImplement = new Ca();
        Abstraction a = new RefinedAbstraction(iImplement);

        a.operation();
    }

    private static abstract class Abstraction {

        protected IImplement iImplement;

        public Abstraction(IImplement iImplement) {
            this.iImplement = iImplement;
        }

        public void operation() {
            this.iImplement.operationImpl();
        }
    }

    private static class RefinedAbstraction extends Abstraction {

        public RefinedAbstraction(IImplement iImplement) {
            super(iImplement);
        }

        @Override
        public void operation() {
            super.operation();
            System.out.println("RefinedAbstraction");
        }
    }

    private interface IImplement {
        void operationImpl();
    }

    private static class Ca implements IImplement {

        @Override
        public void operationImpl() {
            System.out.println(this.getClass().getName());
        }
    }

    private static class Cb implements IImplement {

        @Override
        public void operationImpl() {
            System.out.println(this.getClass().getName());
        }
    }
}
